<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
       <h1>在这里向前走<span id="s">5</span>步</h1>
        <script>
            var sec = 5;
            var sobj = document.getElementById('s');
            function foo() {
                sobj.innerHTML = sec;
                if(sec==0){
                    location.href = 'http://www.baidu.com'
                }
                sec--;
            }
            setInterval(foo,1000)
        </script>
</body>
</html>